package org.opens.javaskill.design;

public class FacadePattern {

    public static void main(String[] args) {
        HospitalDepartmentMaker hospital = new HospitalDepartmentMaker();
        hospital.dentalDiagnosis();
        hospital.ophthalmologyDiagnosis();
        hospital.orthopedicsDiagnosis();
    }

}

/**
 * 功能:
 * <p>医院部门接口</p>
 * 说明:
 * <pre>
 *     1. diagnosis表示某个诊室的诊疗方法
 * </pre>
 */
interface HospitalDepartment {

    public void diagnosis();

}

/**
 * 功能:
 * <p>牙科实现</p>
 */
class Dental implements HospitalDepartment {

    @Override
    public void diagnosis() {
        System.out.println("对牙齿进行了治疗");
    }

}

/**
 * 功能:
 * <p>眼科实现</p>
 */
class Ophthalmology implements HospitalDepartment {

    @Override
    public void diagnosis() {
        System.out.println("对眼睛进行了治疗");
    }

}

/**
 * 功能:
 * <p>骨科实现</p>
 */
class Orthopedics implements HospitalDepartment {

    @Override
    public void diagnosis() {
        System.out.println("对骨头进行了治疗");
    }

}

/**
 * 功能:
 * <p>外观模式的核心类</p>
 * 说明:
 * <pre>
 *     1. 这个类包含了负责功能的实现的所有方法, 去对应的科室只需要调用对应的方法即可.
 * </pre>
 */
class HospitalDepartmentMaker {

    private final Dental dental;
    private final Orthopedics orthopedics;
    private final Ophthalmology ophthalmology;

    public HospitalDepartmentMaker() {
        dental = new Dental();
        orthopedics = new Orthopedics();
        ophthalmology = new Ophthalmology();
    }

    /**
     * 功能:
     * <p>牙科治疗</p>
     */
    public void dentalDiagnosis() {
        dental.diagnosis();
    }

    /**
     * 功能:
     * <p>骨科治疗</p>
     */
    public void orthopedicsDiagnosis() {
        orthopedics.diagnosis();
    }

    /**
     * 功能:
     * <p>眼科治疗</p>
     */
    public void ophthalmologyDiagnosis() {
        ophthalmology.diagnosis();
    }

}